package com.googlecode.animator.core
{
	import com.googlecode.animator.controller.AddCameraCommand;
	import com.googlecode.animator.controller.AddCameraProxiesCommand;
	import com.googlecode.animator.controller.AddDefaultCamerasCommand;
	import com.googlecode.animator.controller.AddDefaultViewportsCommand;
	import com.googlecode.animator.controller.AddObject3DCommand;
	import com.googlecode.animator.controller.AddViewportCommand;
	import com.googlecode.animator.controller.AppStartupCommand;
	import com.googlecode.animator.controller.CameraZoomChangedCommand;
	import com.googlecode.animator.controller.DeleteObject3DCommand;
	import com.googlecode.animator.controller.OpenProjectCommand;
	import com.googlecode.animator.controller.FileSavePathCommand;
	import com.googlecode.animator.controller.MaterialsFileObjectSelectedCommand;
	import com.googlecode.animator.controller.MaterialsRemoveFileObjectCommand;
	import com.googlecode.animator.controller.NewProjectCommand;
	import com.googlecode.animator.controller.Object3DReleasedCommand;
	import com.googlecode.animator.controller.Object3DSelectedCommand;
	import com.googlecode.animator.controller.ProjectAddSceneCommand;
	import com.googlecode.animator.controller.ResetProjectCommand;
	import com.googlecode.animator.controller.PropertiesSWFLoadedCommand;
	import com.googlecode.animator.controller.PropertiesUpdateMaterialCommand;
	import com.googlecode.animator.controller.PropertiesUpdatePropertyCommand;
	import com.googlecode.animator.controller.SaveProjectCommand;
	import com.googlecode.animator.controller.TimelineAddGlobalMarkerCommand;
	import com.googlecode.animator.controller.TimelineAddHideMarkerCommand;
	import com.googlecode.animator.controller.TimelineAddKeyframeCommand;
	import com.googlecode.animator.controller.TimelineCalculateTweensCommand;
	import com.googlecode.animator.controller.TimelineGlobalMarkerMovedCommand;
	import com.googlecode.animator.controller.TimelineHideMarkerMovedCommand;
	import com.googlecode.animator.controller.TimelineKeyframeMovedCommand;
	import com.googlecode.animator.controller.TimelineRemoveGlobalMarkerCommand;
	import com.googlecode.animator.controller.TimelineRemoveHideMarkerCommand;
	import com.googlecode.animator.controller.TimelineRemoveKeyframeCommand;
	import com.googlecode.animator.controller.TimelineScrubObjects3DCommand;
	import com.googlecode.animator.controller.TimelineSetCurrentTimeIntervalCommand;
	import com.googlecode.animator.controller.TimelineSetKeyframePositionCommand;
	import com.googlecode.animator.controller.UpdateViewportCommand;
	import com.googlecode.animator.controller.ZoomControlChangedCommand;
	import com.googlecode.animator.data.Notifications;
	
	import mx.core.Application;
	
	import org.puremvc.as3.patterns.facade.Facade;
	
	/**
	 * PureMVC Facade implementation for 3DAnimator
	 * 
	 * Implements the Singleton interface.
	 *  
	 * @author Martin
	 */
	public class Animator3DFacade extends Facade
	{
		public function Animator3DFacade()
		{
			super();
		}
		
		/**
		 * Application startup function.
		 * @param appRef Reference to the main application instance.
		 */
		public static function start(appRef:Application):void
		{
			getInstance().sendNotification(Notifications.APP_START, appRef);
		}
		
		static public function getInstance():Animator3DFacade
		{
			
			if(instance == null)
			{
				instance = new Animator3DFacade();
			}
			
			return instance as Animator3DFacade;
		}
		
		override protected function initializeController():void
		{
			super.initializeController();
			
			// startup command
			// Note: No Mediators registered at this stage
			registerCommand(Notifications.APP_START, AppStartupCommand);
			
			// add the 3d scene command
			registerCommand(Notifications.ADD_SCENE, ProjectAddSceneCommand);
			
			// launch project macro command
			registerCommand(Notifications.NEW_PROJECT, NewProjectCommand);
			
			// launch project macro command
			//registerCommand(Notifications.PROJECT_LAUNCH_MACRO_COMMAND, ProjectLaunchMacroCommand);
			
			// reset project command
			registerCommand(Notifications.RESET_PROJECT, ResetProjectCommand);
			
			// open project command
			registerCommand(Notifications.OPEN_PROJECT, OpenProjectCommand);
			
			// save project command
			registerCommand(Notifications.SAVE_PROJECT, SaveProjectCommand);
			
			// save project command
			registerCommand(Notifications.FILE_SAVE_PATH, FileSavePathCommand);
			
			// add camera command
			registerCommand(Notifications.ADD_CAMERA, AddCameraCommand);
			
			// add default cameras command
			registerCommand(Notifications.ADD_DEFAULT_CAMERAS, AddDefaultCamerasCommand);
			
			// add default viewports command
			registerCommand(Notifications.ADD_DEFAULT_VIEWPORTS, AddDefaultViewportsCommand);
			
			// add camera proxies command
			registerCommand(Notifications.ADD_CAMERA_PROXIES, AddCameraProxiesCommand);
			
			// add object3D command
			registerCommand(Notifications.ADD_OBJECT3D, AddObject3DCommand);
			
			// delete object3D command
			registerCommand(Notifications.DELETE_OBJECT3D, DeleteObject3DCommand);
			
			// mouse up on a DisplayObject3D command
			registerCommand(Notifications.MOUSE_UP_OBJECT3D, Object3DReleasedCommand);
			
			// object3D selected command
			registerCommand(Notifications.OBJECT3D_SELECTED, Object3DSelectedCommand);
			
			// add viewport command
			registerCommand(Notifications.ADD_VIEWPORT, AddViewportCommand);
			
			// zoom control changed command
			registerCommand(Notifications.ZOOM_CONTROL_CHANGED, ZoomControlChangedCommand);
			
			// update camera settings commands
			registerCommand(Notifications.UPDATE_CAMERA_SETTINGS, CameraZoomChangedCommand);
			
			// add keyframe command
			registerCommand(Notifications.TIMELINE_ADD_KEYFRAME, TimelineAddKeyframeCommand);
			
			// remove keyframe command
			registerCommand(Notifications.TIMELINE_REMOVE_KEYFRAME, TimelineRemoveKeyframeCommand);
			
			// keyframe moved command
			registerCommand(Notifications.TIMELINE_KEYFRAME_MOVED, TimelineKeyframeMovedCommand);
			
			// set keyframe position information
			registerCommand(Notifications.TIMELINE_SET_KEYFRAME_POSITION, TimelineSetKeyframePositionCommand);
			
			// keyframe moved command
			//registerCommand(Notifications.TIMELINE_CALCULATE_TWEENS, TimelineCalculateTweensCommand);
			
			// set current time interval
			registerCommand(Notifications.TIMELINE_SET_CURRENT_TIME_INTERVAL, TimelineSetCurrentTimeIntervalCommand);
			
			// move objects3D in scene
			registerCommand(Notifications.TIMELINE_SCRUB_OBJECTS3D, TimelineScrubObjects3DCommand);
			
			// add hide marker command
			registerCommand(Notifications.TIMELINE_ADD_HIDE_MARKER, TimelineAddHideMarkerCommand);
			
			// remove hide marker command
			registerCommand(Notifications.TIMELINE_REMOVE_HIDE_MARKER, TimelineRemoveHideMarkerCommand);
			
			// update hide marker command
			registerCommand(Notifications.TIMELINE_HIDE_MARKER_MOVED, TimelineHideMarkerMovedCommand);
			
			// add global marker command
			registerCommand(Notifications.TIMELINE_ADD_GLOBAL_MARKER, TimelineAddGlobalMarkerCommand);
			
			// remove global marker command
			registerCommand(Notifications.TIMELINE_REMOVE_GLOBAL_MARKER, TimelineRemoveGlobalMarkerCommand);
			
			// update global marker command
			registerCommand(Notifications.TIMELINE_GLOBAL_MARKER_MOVED, TimelineGlobalMarkerMovedCommand);
			
			// materials file path selected command
			registerCommand(Notifications.MATERIALS_FILE_PATH_SELECTED, MaterialsFileObjectSelectedCommand);
			
			// materials remove FileObjectVO command
			registerCommand(Notifications.MATERIALS_REMOVE_FILE_OBJECT, MaterialsRemoveFileObjectCommand);
			
			// properties change property command
			registerCommand(Notifications.UPDATE_OBJECT3D_PROPERTY, PropertiesUpdatePropertyCommand);
			
			// properties change property command
			registerCommand(Notifications.OBJECT3D_SWF_LOADED, PropertiesSWFLoadedCommand);
			
			// properties change material command
			registerCommand(Notifications.UPDATE_OBJECT3D_MATERIAL, PropertiesUpdateMaterialCommand);
			
			// update viewport command
			registerCommand(Notifications.VIEWPORT_UPDATED, UpdateViewportCommand);
		}

	}
}